package com.kongfanyu.springcloud.service.impl;

import com.kongfanyu.springcloud.dao.AccountDao;
import com.kongfanyu.springcloud.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * Copyright (C), 2018-2020
 * FileName: StorageServiceImpl
 * Author:   kongfanyu
 * Date:     2020/9/6 14:00
 */
@Slf4j
@Service
public class AccountServiceImpl implements AccountService {

    @Resource
    private AccountDao accountDao;
    @Override
    public void decrease(Long userId, BigDecimal money) {
        log.info("-------》库存微服务开始扣减金额");
        //TODO: 做个超时异常
        //try { TimeUnit.SECONDS.sleep(20); } catch (InterruptedException e) { e.printStackTrace(); }
        accountDao.decrease(userId,money);
        log.info("-------》库存微服务结束扣减金额");
    }
}
